package com.x.ant.service;

import com.x.ant.dao.LineDao;
import com.x.ant.model.Line;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class LineService extends BaseService {
    @Autowired
    private LineDao lineDao;

    public List<Line> selectLineList(Line line) {
        try {
            return lineDao.selectLineList(line);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public int selectLineNum(Line line) throws Exception{
        try {
            return lineDao.selectLineNum(line);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public Line insertLine(Line line) {
        try {
            line.setLineCreateDate(this.getDate(0));
            return this.insert(line);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public void updateLine(Line line) {
        try {
            line.setLineCreateDate(this.getDate(0));
            this.update(line);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

}
